import language from './zh_cn';

const getValue = (key, keyChain, language) => {

    if (keyChain.length) {
        return getValue(keyChain.shift(), keyChain, language[key])
    } else {
        return language[key];
    }
}

const translate = (name) => {
    var keyChain = name.split('.');
    var result = getValue(keyChain.shift(), keyChain, language);

    return typeof result === 'string' ? result : name;
}

export default translate;

